<?php

namespace app\adminapi\export;


use app\services\product\product\StoreProductServices;
use Carbon\Carbon;

class StoreProductExport extends BaseExport
{
    protected $header = [
        '商品', '分类', '价格(元)', '商品状态', '更新时间'
    ];

    public function createData(array $where)
    {
        $list = app()->make(StoreProductServices::class)->getList($where)['list'];

        $data = [];

        foreach ($list as $item) {
            $data[] = [
                $item['store_name'],
                $item['cate_name'],
                $item['price'],
                ($item['is_show'] == 1 ? '上架' : '下架'),
                Carbon::parse($item['add_time'])->format('Y-m-d H:i:s')
            ];
        }

        return $data;
    }
}